package jp.ac.segakuen;

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;


public class SelectListTableServlet extends HttpServlet{

  /**
	 * 
	 */
	private static final long serialVersionUID = -244660098758271253L;
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException ,ServletException {
	    String action = req.getParameter("submit");
	    if (action.equals("削除")) {
	    	  SelectListTableUtils.resetbyId(req.getParameter("delid"));
	    	  OpenCampassMenuTableUtil.deleteByDateName(req.getParameter("listtext"));
	    	  if (req.getParameter("placeholder").equals("examdate")){
	    		  resp.sendRedirect("/ajaxmail/listExaminData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("ocdate")){
	    		  resp.sendRedirect("/ajaxmail/listOCData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("occourse")){
	    		  resp.sendRedirect("/ajaxmail/listOCItemData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("taiken")){
	    		  resp.sendRedirect("/ajaxmail/listXPData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("itcenter")){
	    		  resp.sendRedirect("/ajaxmail/listITData.jsp");
	    	  }
	      } else if (action.equals("Add")) {
	    	  SelectListTableUtils.insertNew(req.getParameter("sortorder"),req.getParameter("listtext"),req.getParameter("placeholder"));
	    	  if (req.getParameter("placeholder").equals("examdate")){
	    		  resp.sendRedirect("/ajaxmail/listExaminData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("ocdate")){
	    		  resp.sendRedirect("/ajaxmail/listOCData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("occourse")){
	    		  resp.sendRedirect("/ajaxmail/listOCItemData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("taiken")){
	    		  resp.sendRedirect("/ajaxmail/listXPData.jsp");
	    	  }else if(req.getParameter("placeholder").equals("itcenter")){
	    		  resp.sendRedirect("/ajaxmail/listITData.jsp");
	    	  }
	      }else if(action.equals("内容編集")){
	    	  getServletContext().getRequestDispatcher("/ajaxmail/listOCDateItemData.jsp").forward(req,resp);
    	  
	      }   else {
	      
	      }  
	    }
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	throws IOException,ServletException{
		doPost(req,resp);
	}
}
